package com.lijian.netty.socket2.server;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author lj02
 * @desc
 * @date 2018/11/22
 */
public class HelloServerChannelHandlerAdapter extends SimpleChannelInboundHandler<String> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, String msg) throws Exception {
        System.out.println(" channelRead0 -- client msg is " + msg);
        System.out.println(" channelRead0 -- " + ctx.channel().remoteAddress());

        ctx.channel().writeAndFlush(System.currentTimeMillis()+" ssss ");
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        super.exceptionCaught(ctx, cause);
        ctx.close();
        System.out.println("exceptionCaught");
    }
}
